package com.burpee.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.burpee.dao.FoodDaoImpl;
import com.burpee.service.ChoiceService;
import com.burpee.service.ExerciseOrderService;
import com.burpee.service.ExerciseService;
import com.burpee.service.FoodService;
import com.burpee.ui.Boarditems;
import com.burpee.ui.Exercise;
import com.burpee.ui.Food;
import com.burpee.ui.Member;
import com.sun.xml.internal.ws.resources.HttpserverMessages;

@Controller
@RequestMapping("/schedule.spring")
public class ScheduleController {

	@Autowired ExerciseService exerciseService;
	@Autowired FoodService foodService;

	//	@Autowired
	//	ExerciseOrderService exerciseOrderService;
	//	@Autowired
	//	ChoiceService choiceService;

	
	
	/**
	 * @Method Name : foodMain
	 * @date : 2013. 8. 1.
	 * @author : LEESANGUCK
	 * @history : 음식/영양 
	 * @param request * @param response * @param food
	 * @return
	 */ 	
	@RequestMapping(params ="action=foodMain")
	public ModelAndView foodMain( HttpServletRequest request,
							      HttpServletResponse response,
								  Food food ){
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("food/foodMain");
		return modelAndView;
	}
	
	@RequestMapping(params ="action=totalFoodInformation")
	public ModelAndView totalFoodInformation( HttpServletRequest request,
							      			  HttpServletResponse response,
							      			  Food food ){
		
		List<Food>list = null;
		list = foodService.list();

		ModelAndView modelAndView = new ModelAndView();
		
		modelAndView.addObject("foodList", list);
		modelAndView.addObject("food", "A");
		modelAndView.setViewName("food/foodInformationPage");
		return modelAndView;
	}

	@RequestMapping(params ="action=foodClassSelectList")
	public ModelAndView foodClassSelectList( HttpServletRequest request,
											   HttpServletResponse response,
											   Food food){
			
		return null;
	}
	
	@RequestMapping(params ="action=foodIngestPurposeSelectList")
	public ModelAndView foodIngestPurposeSelectList( HttpServletRequest request,
													 HttpServletResponse response,
													 Food food){
		List<Food>list = null;
		food.setFoodIngestPurpose(request.getParameter("foodIngestPurpose"));
		
		list = foodService.foodIngestPurposeSelectList(food);
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("foodList", list);
		modelAndView.addObject("food", food.getFoodIngestPurpose());
		modelAndView.setViewName("food/foodInformationPage");
		return modelAndView;
	}
	
	
	
	
	/**
	 * @Method Name : exerciselist
	 * @date : 2013. 8. 2.
	 * @author : LEESANGUCK
	 * @history :  헬스 관리
	 * @param request * @param response * @param exercise
	 * @return
	 */ 	
	@RequestMapping(params = "action=exerciselist")
	public ModelAndView exerciselist(HttpServletRequest request, HttpServletResponse response, Exercise exercise){ List<Exercise> exerciselist = exerciseService.list(exercise);
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("exerciseList",exerciselist);
		modelAndView.setViewName("health/mysports");

		return modelAndView;

	}
	
	@RequestMapping(params ="action=exercisePurposeSelectList")
	public ModelAndView exercisePurposeSelectList( HttpServletRequest request, 
												   HttpServletResponse response,
												   Exercise exercise){
		List<Exercise>list = null;
		
		exercise.setExercisePurpose(request.getParameter("exercisePurpose"));
		list = exerciseService.exercisePurposeSelectList(exercise);

		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("exerciseList", list);
		modelAndView.addObject("exercise", exercise.getExercisePurpose());
		modelAndView.setViewName("health/sportInformationPage");

		return modelAndView;
	}
	
}






